import type { BasicColumn, FormSchema } from '@/components/Table'
import { useRender } from '@/components/Table'
import { DICT_TYPE, getDictOptions } from '@/utils/dict'

export const columns: BasicColumn[] = [
  {
    title: '设备名称',
    dataIndex: 'name',
    width: 160,
  },
  {
    title: '设备编码',
    dataIndex: 'code',
    width: 160,
  },
  {
    title: '设备状态',
    dataIndex: 'status',
    width: 160,
    customRender: ({ text }) => {
      return useRender.renderDict(text, DICT_TYPE.VR_DEVICE_STATUS)
    },
  },
  {
    title: '创建时间',
    dataIndex: 'createTime',
    width: 180,
    customRender: ({ text }) => {
      return useRender.renderDate(text)
    },
  },
]

export const searchFormSchema: FormSchema[] = [
  {
    label: '设备名称',
    field: 'name',
    component: 'Input',
    colProps: { span: 8 },
  },
  {
    label: '设备编码',
    field: 'code',
    component: 'Input',
    colProps: { span: 8 },
  },
  {
    label: '设备状态',
    field: 'status',
    component: 'Select',
    componentProps: {
      options: getDictOptions(DICT_TYPE.VR_DEVICE_STATUS),
    },
    colProps: { span: 8 },
  },
  {
    label: '创建时间',
    field: 'createTime',
    component: 'RangePicker',
    colProps: { span: 8 },
  },
]

export const createFormSchema: FormSchema[] = [
  {
    label: '编号',
    field: 'id',
    show: false,
    component: 'Input',
  },
  {
    label: '设备名称',
    field: 'name',
    required: true,
    component: 'Input',
  },
  {
    label: '设备编码',
    field: 'code',
    required: true,
    component: 'Input',
  },
  {
    label: '设备状态',
    field: 'status',
    required: true,
    component: 'RadioButtonGroup',
    componentProps: {
      options: getDictOptions(DICT_TYPE.VR_DEVICE_STATUS),
    },
  },
]
export const deviceGameSchema: FormSchema[] = [
  {
    label: '编号',
    field: 'deviceId',
    show: false,
    component: 'Input',
  },
  {
    label: '编号',
    field: 'gameId',
    show: false,
    component: 'Input',
  },
]

export const updateFormSchema: FormSchema[] = [
  {
    label: '编号',
    field: 'id',
    show: false,
    component: 'Input',
  },
  {
    label: '设备名称',
    field: 'name',
    required: true,
    component: 'Input',
  },
  {
    label: '设备编码',
    field: 'code',
    required: true,
    component: 'Input',
  },
  {
    label: '设备状态',
    field: 'status',
    required: true,
    component: 'RadioButtonGroup',
    componentProps: {
      options: getDictOptions(DICT_TYPE.VR_DEVICE_STATUS),
    },
  },
]
